﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;

/// <summary>
/// Summary description for update_Status
/// </summary>
/// 

namespace Bestlife.ERP.BusinessRules
{
    public class update_Status
    {
        String  usr;
        String sqlqry;
        SqlDataReader rdrssqll;
        Double fval;
        public update_Status()
        {
            //
            // TODO: Add constructor logic here
            //
        }


        public void Get_child_node(List<string> childList)
        {

            ////            int[] myInterger = new int[1];
            ////int total = 0;
            ////foreach(int i in myInterger) 
            ////{
            ////    total += i;
            ////}

            foreach (String ch in childList)
            {

                string childid = ch;


                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);

              
                sqlqry = "SELECT d.Dis_ID From Distributor_Level dl,Tbl_Distributor d WHERE d.Sup_ID='" + childid + "' AND d.Sup_ID=dl.User_id";
                rdrssqll = Bestlife.ERP.DataAccess.clsCon.ReadTable(sqlqry);


                 while (rdrssqll.Read())
                {
                    // parentID = rdRStatus["user_Status"].ToString();

                    usr = rdrssqll["Dis_ID"].ToString();


                     ///// Recall 





                }

                 rdrssqll.Close();


            }


            //try
            //{//try

            //    String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
            //    Bestlife.ERP.DataAccess.clsCon.connect(connStr);

            //    SqlDataReader rdrssql;
            //    rdrssql = Bestlife.ERP.DataAccess.clsCon.ReadTable(ssql);

            //    while (rdrssql.Read())
            //    {
            //        // parentID = rdRStatus["user_Status"].ToString();

            //        usr = rdrssql["User_id"].ToString();

            //    }


            }


        public Double storeComm (String id, Double directCom)
        {
                
                String connStr = ConfigurationManager.ConnectionStrings["MainConnStr"].ConnectionString;
                Bestlife.ERP.DataAccess.clsCon.connect(connStr);

               
                String sqlqry2 = "SELECT Store_comm FROM bonus WHERE User_id='"+id+"'";
                rdrssqll = Bestlife.ERP.DataAccess.clsCon.ReadTable(sqlqry2);


                 while (rdrssqll.Read())
                 {
                    // parentID = rdRStatus["user_Status"].ToString();

                    Double val =double.Parse(rdrssqll["Store_comm"].ToString());
                    fval= val+directCom;

                  }

                 rdrssqll.Close();
                 return fval;
                
                  }

        
        }




    
}